// src/server/index.js
import React from "react"; // 不引入会报错
import app from './http.js'
import Home from "../share/pages/Home.js";
import {renderToString} from "react-dom/server";

app.get('/', (req, res) => {
    const content = renderToString(<Home/>)
    res.send(`
        <html>
            <head>
                <title>react ssr</title>
            </head>
            <body>
                <div id="root">${content}</div>
                <!--拿到client打包的js-->
                <script src="bundle.js"></script>
            </body>
        </html>
    `)
})